<extend name="./public/frame.html"/>
<block name="content">
	<div class="layui-row">
		<div class="layui-col-xs3">
			<div class="layui-btn-group">
				<button class="layui-btn layui-btn-warm" data-url="{:url('version_add')}" onclick="add_t(this,'添加城市')">
					添加版本
				</button>
			</div>
		</div>
	</div>
	<table class="layui-table"
		   lay-data="{width:'auto', height:'auto', url:'{:url('System/version')}', page: true, limit: 10, id:'test'}"
		   lay-filter="test">
		<thead>
		<tr>
			<th lay-data="{checkbox:true, fixed: true}"></th>
			<th lay-data="{field:'id', width:70, fixed: true, sort: true}">ID</th>
			<th lay-data="{field:'version_name', width:150, fixed: true, sort: true}">版本名称</th>
			<th lay-data="{field:'content', width:100, sort: true}">内容</th>
			<th lay-data="{field:'time', width:150, sort: true}">时间</th>
			<th lay-data="{fixed:'right', toolbar: '#barDemo', width:250, align:'center'}">操作</th>
		</tr>
		</thead>
	</table>
	<script type="text/html" id="barDemo">
		<a class="layui-btn layui-btn-sm" lay-event="edit" style="width: 70px">修改</a>
		<a class="layui-btn layui-btn-sm" lay-event="del" style="width: 70px">删除</a>
	</script>
	<script>
		layui.use(['table','form'], function () {
			var table = layui.table;
			//监听工具条
			table.on('tool(test)', function (obj) {
				var data = obj.data;
				var id = data.id;

				if (obj.event === 'del') {
					layer.confirm('确定删除吗?',function(index){
						var url = '{:url("/admin/system/version_add","del=1&id=")}' + id
						$.get(url,function(data){
							if(data.status == 1){
								layer.msg('成功删除',{'icon':1});
								window.location.reload();
							}else{
								layer.msg('操作失败',{'icon':2});
							}
						},'json')
						layer.close(index);
					})
			
				} else if (obj.event === 'edit') {
					layer.open({
						type: 2,
						title: '版本修改',
						shadeClose: true,
						shade: 0.8,
						area: ['100%', '100%'],
						content: '{:url("/admin/system/version_add","id=")}' + id //iframe的url
					});
				
				}
			});
		});

	</script>
</block>
